USE [Capstone]
GO

/****** Object:  StoredProcedure [dbo].[SaveNote]    Script Date: 07/22/2012 22:45:05 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[SaveNote] 
	-- Add the parameters for the stored procedure here
	@NotesID int = NULL,
	@calID int,
	@UserID int,
	@Note text
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	if (@NotesID = 0)
	Begin
		Insert into Notes
			(calID, UserID, CreatedDate, Note)
		values
			(@calID, @UserID, GetDate(), @Note)
	End
	Else
	Begin
		update Notes set
			calID = @calID, UserID = @UserID, CreatedDate=GetDate(),
			Note=@Note
	End

Select Scope_Identity();
END

GO

